package com.yes_iot.dao;

import com.yes_iot.entity.LargeScreenConfiguration;
import com.yes_iot.entity.LargeScreenMoudle;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.UUID;

@Repository
public interface LargeScreenConfigurationDao extends JpaRepository<LargeScreenConfiguration, UUID> {

    @Query("select lsc from LargeScreenConfiguration lsc where lsc.id in :ids ")
    List<LargeScreenConfiguration> findByIds(@Param("ids") List<UUID> ids);

    @Query("select lsc from LargeScreenConfiguration lsc where lsc.farmId in :farmIds ")
    List<LargeScreenConfiguration> findByFarmIds(@Param("farmIds")List<Integer> farmIds);

    @Query("update LargeScreenConfiguration set farmId=:#{#largeScreenConfiguration.farmId}," +
            "farmName=:#{#largeScreenConfiguration.farmName}," +
            "greenHouseId=:#{#largeScreenConfiguration.greenHouseId}," +
            "greenHouseName=:#{#largeScreenConfiguration.greenHouseName}," +
            "deviceId=:#{#largeScreenConfiguration.deviceId}," +
            "deviceMeta=:#{#largeScreenConfiguration.deviceMeta}," +
            "name=:#{#largeScreenConfiguration.name}, " +
            "loginLogo=:#{#largeScreenConfiguration.loginLogo}, " +
            "loginText=:#{#largeScreenConfiguration.loginText} " +
            "where id=:#{#largeScreenConfiguration.id} ")
    @Modifying
    void basicUpdate(@Param("largeScreenConfiguration")LargeScreenConfiguration largeScreenConfiguration);
    @Query("update LargeScreenConfiguration set content=:#{#largeScreenConfiguration.content}," +
            "config=:#{#largeScreenConfiguration.config} " +
            "where id=:#{#largeScreenConfiguration.id} ")
    @Modifying
    void visualUpdate(@Param("largeScreenConfiguration")LargeScreenConfiguration largeScreenConfiguration);
}
